package pre.liuxl.blog.service.serviceImpl;

import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pre.liuxl.blog.entity.Permission;
import pre.liuxl.blog.entity.RolePermission;
import pre.liuxl.blog.entity.User;
import pre.liuxl.blog.entity.UserRole;
import pre.liuxl.blog.repository.PermissionRepository;
import pre.liuxl.blog.repository.RolePermissionRepository;
import pre.liuxl.blog.repository.UserRepository;
import pre.liuxl.blog.repository.UserRoleRepository;
import pre.liuxl.blog.service.UserService;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liuxuanlong on 2018/6/23.
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserRepository userRepository;
    @Autowired
    PermissionRepository permissionRepository;
    @Autowired
    RolePermissionRepository rolePermissionRepository;
    @Autowired
    UserRoleRepository userRoleRepository;

    @Override
    public User loginCheck(String userName, String password) {
        User user = userRepository.findByUserNameAndPassword(userName, password);
        return user;
    }

    @Override
    public List<Permission> findUserPermissionByUserId(Integer userId) {
        return permissionRepository.findByUserId(userId);

    }
}
